package com.psy.counseling.controller;

import com.psy.counseling.entity.Test;
import com.psy.counseling.entity.TestResult;
import com.psy.counseling.service.ResultService;
import com.psy.counseling.service.TestResultService;
import com.psy.counseling.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/testResult")
public class TestResultController {

@Resource
private TestResultService testResultService;
@Resource
private ResultService resultService;
    @PostMapping
    public Result<?> save(@RequestBody TestResult testResult) {
        String testinfo = resultService.getResultInfoById(testResult);
        testResult.setResultInfo(testinfo);
        testResultService.insertTestResult(testResult);
        return Result.success();
    }
    @GetMapping
    public Result<?> findAll() {
        List<TestResult> list = testResultService.list();
        return Result.success(list);
    }
}
